﻿using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;

namespace DSLPedProjectWizard
{
    public class NewProjectWizard : IWizard
    {
        public void BeforeOpeningFile(ProjectItem projectItem)
        {
        }

        public void ProjectFinishedGenerating(Project project)
        {
        }

        public void ProjectItemFinishedGenerating(ProjectItem projectItem)
        {
        }

        public void RunFinished()
        {
        }

        public void RunStarted(object automationObject, System.Collections.Generic.Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            var projectWizard = new MainWizardWindow();
            projectWizard.ShowDialog();

            var result = projectWizard.DialogResult;
            if (result == true)
            {
                var languageName = projectWizard.LanguageName;
                replacementsDictionary.Add("$languageName$", languageName);

                var languageXmlNamespace = projectWizard.LanguageXmlNamespace;
                replacementsDictionary.Add("$languageXmlNamespace$", languageXmlNamespace);

                var languageDescription = projectWizard.LanguageDescription;
                replacementsDictionary.Add("$languageDescription$", languageDescription);
            }
            else
            {
                throw new WizardCancelledException();
            }
        }

        public bool ShouldAddProjectItem(string filePath)
        {
            return true;
        }
    }
}
